import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
  ScrollView,
  Image,
  TextInput,
  ListView,
  NativeAppEventEmitter,
  DeviceEventEmitter,
  TouchableOpacity,
  TouchableHighlight,
  ActivityIndicator,
  Dimensions,
  Platform,
  Alert,
  Modal,
  InteractionManager,
} from 'react-native';

import dismissKeyboard from 'dismissKeyboard';

import AMapLocation from 'react-native-smart-amap-location';
import AMap from '../global/amapView/AMap';
import PullToRefreshListView from 'react-native-smart-pull-to-refresh-listview';

import ScrollableTabView from 'react-native-scrollable-tab-view';

import styles from './editOrderStyle';
import CustomListView from '../global/CustomListView';
import ListViewActivityIndicator from '../global/ListViewActivityIndicator';
import DefaultTabBar from '../global/scrollableTabView/DefaultTabBar';

import HistoryAddrList from './historyAddrList';

import api from '../../services/api';
import ToastTip from '../global/ToastTip';
import SimpleDialog from '../global/SimpleViewDialog';

const {width: deviceWidth, height: deviceHeight} = Dimensions.get('window');
const SUPPORTED_ORIENTATIONS = ['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right'];

class EditAddress extends Component {
    constructor(props) {
		super(props);

        let {address_store, location_store, addrContent, roomInfo, roomLocation} = props;
        let address_left = address_store && address_store.split('\n')[0];
        let address_right = address_store && address_store.split('\n')[1];
        let latitude_init = location_store && location_store.split(',')[0];
        let longitude_init = location_store && location_store.split(',')[1];

		this.state = {
            isLoading: true,
			isRefreshing: false,
			currentPage: 1,
            addressFirst: address_left,
            addressSecond: address_right,
            modalVisible: false,
            searchDataSource: null,
            code:null,
            location: location_store,
            nodata: false,
            showMap: true,
            addrContent,
            roomInfo,
            roomLocation
		};

        this._amap = null;
        this._page = 0;
        this._coordinate = {
            latitude: parseFloat(latitude_init) || 0,
            longitude: parseFloat(longitude_init) || 0,
        };

        console.log(`this._coordinate -> `, this._coordinate);

        // console.log(this._coordinate)
        this._keywords = '商务住宅|住宅区|住宅小区|学校|大厦|写字楼|地铁';
        this._onDidMoveByUserTimer = null;
        this._subcribLocation = null;
        this._subcribSearch = null;
        this.curCity = '';
        this.location_city = '';
		this.props.navigator.setOnNavigatorEvent(this._onNavigatorEvent.bind(this));
	}

    async _onNavigatorEvent(event){
        if (event.type == 'NavBarButtonPress') {
              if (event.id == 'city') {
                  this.openSelectCity();
              }
        }
        if(event.id == 'didAppear'){
            // this.setState({
            //     showMap:true,
            // });
        }
    }

    async openSelectCity(){
        if(this.state.isDisable){
            return;
        }

        await this.setState({isDisable:true,openArrd:false});//防重复点击
        this.props.navigator.push({
                 title: '选择城市',
                 screen: 'housekeeperapp.orderselectcity',
                 backButtonTitle:'',
                  passProps: {
                        city: this.curCity,
                        code: this.state.code,
                        location_city: this.location_city
                  },
                  navigatorStyle:{
                    tabBarHidden: true,
                    navBarTextColor: 'white',
                    navBarButtonColor: 'white',
                    navBarBackgroundColor: '#EA5404',
                    statusBarColor: '#EA5404',
                  //   navBarHidden: true,
                    navBarTitleTextCentered: true,
                    topBarElevationShadowEnabled:false
                },
                navigatorButtons: {
                    leftButtons:[
                        {
                            id: 'back',
                            icon: require("../../../img/hk_back_icon.png")
                        }
                    ]
                }
          });

          this.timer = setTimeout(async() =>{
              await this.setState({isDisable:false});//1.0秒后可点击
          },1000);
    }

    componentWillMount(){

    }

    componentDidMount() {
        let Emitter = Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter;
        this._subcribLocation = Emitter.addListener('amap.location.onLocationResult', this._onLocationResult.bind(this));
        this._subcribUpdateCity = Emitter.addListener('update.city', this.updateCurCity.bind(this));

        if(this._coordinate.latitude == 0 && this._coordinate.longitude == 0){
            AMapLocation.init(null);
            AMapLocation.getReGeocode();
        }else{

            this._activityIndicator.setState({ visible: true,});
            //附近地址
            let Emitter = Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter;
            this._subcribSearch = Emitter.addListener('amap.onPOISearchDone', this._onPOISearchDone.bind(this));

            setTimeout(() =>{
                this._amap.setOptions({
                    zoomLevel: 14.1,
                });
                this._amap.setCenterCoordinate(this._coordinate);

                this._amapALoneNearByList._pullToRefreshListView._scrollView.scrollTo({ y: 0, animated: false, });
                this._amapALoneNearByList._pullToRefreshListView.beginRefresh(true);
                this._beginRefresh = true;

            },500);

        }

    }

    componentWillUnmount () {
        //停止并销毁定位服务
        AMapLocation.cleanUp();
        this._subcribLocation && this._subcribLocation.remove();
        this._subcribSearch && this._subcribSearch.remove();
        this._subcribUpdateCity && this._subcribUpdateCity.remove();
        this.timer && clearTimeout(this.timer);
    }

    _addAddress(type){
        let title = '';
        switch(type){
            case 'send':
                title = '填写寄件地址';
                break;
            case 'receive':
                title = '填写收货地址';
                break;
        }

        this.props.navigator.push({
            title: title,
			screen: 'housekeeperapp.addorder',
            backButtonTitle:'',
			passProps: {
				// orderId
			},
            navigatorStyle:{
                tabBarHidden: true,
                navBarTextColor: 'white',
            	navBarButtonColor: 'white',
            	navBarBackgroundColor: '#EA5404',
                statusBarColor: '#EA5404',
                navBarTitleTextCentered: true,
                topBarElevationShadowEnabled:false
            },
            navigatorButtons: {
                leftButtons:[
                    {
                        id: 'back',
                        icon: require("../../../img/hk_back_icon.png")
                    }
                ]
            }
		});
    }

    updateCurCity(city){
        console.log("#####", city);

        this.props.navigator.setButtons({
            rightButtons: [
                {
                    title: city.length>7?city.substring(0,7)+'...':city,
                    id: 'city',
                    component: 'housekeeperapp.editaddrrightbtn',
                    passProps: {
                        text: city.length>7?city.substring(0,7)+'...':city,
                    },
                }
            ],
            animated: false
        });
        this.curCity = city;
    }

    _addressYezhuAction(){
        let {addrContent, roomInfo, roomLocation} = this.state;
        if (roomLocation) {
            let rowData={
                name: addrContent,
                latitude: parseFloat(roomLocation.split(',')[0]),
                longitude: parseFloat(roomLocation.split(',')[1])
            }

            this._onSearchResultListItemPress(rowData);
        }
        
        this.setState({
            addressSecond: roomInfo
        });
    }

    _onLocationResult(result){
        if(result.error) {
            console.log(`map-错误代码: ${result.error.code}, map-错误信息: ${result.error.localizedDescription}`);
            this.setState({
                openArrd:true,
                code:result.error.code
            });

        }
        else {

            console.log(`map-纬度 = ${result.coordinate.latitude}, map-经度 = ${result.coordinate.longitude}`)
            this._coordinate = {
                latitude: result.coordinate.latitude,
                longitude: result.coordinate.longitude,
            }

            this._amap.setOptions({
                zoomLevel: 14.1,
            });

            this.updateCurCity(result.city);
            this.location_city = result.city;

            this._amap.setCenterCoordinate(this._coordinate);
            InteractionManager.runAfterInteractions(() => {
                //附近地址
                let Emitter = Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter;
                this._subcribSearch = Emitter.addListener('amap.onPOISearchDone', this._onPOISearchDone.bind(this));
            });

        }
    }

    _onPOISearchDone(result){

        if(Platform.OS == 'ios') {
            this._endSearch(result);
        }
        else {
            setTimeout( () => {
                this._endSearch(result);
            }, 255);
        }
    }

    _onDidMoveByUser(e){

        if(this._onDidMoveByUserTimer) {
            clearTimeout(this._onDidMoveByUserTimer);
            this._onDidMoveByUserTimer = null;
        }

        this.setState({noneardata:false});
        //初始化时不需要
        if(this._coordinate.latitude == 0 && this._coordinate.longitude == 0){
            return;
        }

        if(this.clickPressLocation){
            this.clickPressLocation = false;
            return;
        }


        let { longitude, latitude, } = e.nativeEvent.data.centerCoordinate;
        this._onDidMoveByUserTimer = setTimeout(() => {
            if(!this._amapALoneNearByList){
                return;
            }

            let {refresh_none, refresh_idle, load_more_none, load_more_idle, loaded_all,} = PullToRefreshListView.constants.viewState;
            if((this._amapALoneNearByList._pullToRefreshListView._refreshState == refresh_none || this._amapALoneNearByList._pullToRefreshListView._refreshState == refresh_idle)
                && (this._amapALoneNearByList._pullToRefreshListView._loadMoreState == load_more_none
                || this._amapALoneNearByList._pullToRefreshListView._loadMoreState == load_more_idle
                || this._amapALoneNearByList._pullToRefreshListView._loadMoreState == loaded_all)) {

                this._coordinate = {
                    longitude,
                    latitude,
                }

                this._activityIndicator.setState({ visible: true,});
                this._amapALoneNearByList._pullToRefreshListView._scrollView.scrollTo({ y: 0, animated: false, });
                this._amapALoneNearByList._pullToRefreshListView.beginRefresh(true);
                //this._amapALoneNearByList._pullToRefreshListView.beginRefresh()
                this._beginRefresh = true;
            }

        }, 300);
    }

    _endSearch(result){
        let { searchResultList, error } = result;

        // console.log("###", searchResultList);

        // console.log("########", this._amapALoneNearByList);
        if(!this.state.noneardata && !this._amapALoneNearByList){
            return;
        }

        this.setState({noneardata:false});
        if(error) {
            if(this._page == 1) {
                this._page--;
                this._amapALoneNearByList._pullToRefreshListView.endRefresh(this._beginRefresh);
                //this._amapALoneNearByList._pullToRefreshListView.endRefresh()
                this._beginRefresh = false;
                this._activityIndicator.setState({ visible: false,});
            }
            else {
                this._amapALoneNearByList._pullToRefreshListView.endLoadMore(false)
            }
            return;
        }

        if(searchResultList.length == 0){
            this._beginRefresh = false;
            this._activityIndicator.setState({ visible: false,});
            this.setState({nodata:true, noneardata:true});

            this._searchIndicator && this._searchIndicator.setState({ visible: false,});
            return;
        }

        if(this.state.editAddress){
            const ds = new ListView.DataSource({ rowHasChanged: (row1, row2) => row1 !== row2 });
            const dataSource = ds.cloneWithRows(searchResultList);
            this.setState({ searchDataSource: dataSource});
            this._searchIndicator && this._searchIndicator.setState({ visible: false,});
            // return;
        }

        //onRefresh
        if(this._page == 1) {
            this._amapALoneNearByList.setState({
                dataList: searchResultList,
                dataSource: this._amapALoneNearByList._dataSource.cloneWithRows(searchResultList),
            });
            this._amapALoneNearByList._pullToRefreshListView.endRefresh(false);
            //this._amapALoneNearByList._pullToRefreshListView.endRefresh()
            this._beginRefresh = false;
            this._activityIndicator.setState({ visible: false,});
        }
        //onLoadMore
        else {
            let newDataList = this._amapALoneNearByList.state.dataList.concat(searchResultList)
            this._amapALoneNearByList.setState({
                dataList: newDataList,
                dataSource: this._amapALoneNearByList._dataSource.cloneWithRows(newDataList),
            });
            let loadedAll;
            if(searchResultList.length == 100) {
                loadedAll = true;
                this._amapALoneNearByList._pullToRefreshListView.endLoadMore(loadedAll)
            }
            else {
                loadedAll = false;
                this._amapALoneNearByList._pullToRefreshListView.endLoadMore(loadedAll)
            }
        }
    }

    _onRefresh(){
        // console.log(`outer _onRefresh...`);
        this._searchNearBy({
            page: (this._page = 1),
            coordinate: this._coordinate,
            keywords: this._keywords,
        });
    }

    _onLoadMore(){
        this._searchNearBy({
            page: ++this._page,
            coordinate: this._coordinate,
            keywords: this._keywords,
        });
    }

    _onSearchResultListItemPress(rowData){
        // console.log("###", rowData);
        this.setState({
            addressFirst: `${rowData.name}`,
            location: `${rowData.latitude},${rowData.longitude}`
        });
        this.clickPressLocation = true;
        this._setModalVisible(false);

        this._amap.setCenterCoordinate({
            latitude: rowData.latitude,
            longitude: rowData.longitude,
        });

        this._coordinate = {
            longitude: rowData.longitude,
            latitude: rowData.latitude,
        };

        setTimeout(() =>{
            if(this._amapALoneNearByList){
                this._activityIndicator.setState({ visible: true,});
                let listView = this._amapALoneNearByList._pullToRefreshListView;
                listView && listView._scrollView.scrollTo({ y: 0, animated: false, });
                listView && listView.beginRefresh(true);
                this._beginRefresh = true;
            }
        },0);
    }

    _renderRow(rowData, sectionID, rowID, type){
        // console.log("$$$", type);

        return (
            <TouchableOpacity
                style={styles.searchItem}
                activeOpacity={0.7}
                onPress={this._onSearchResultListItemPress.bind(this, rowData)}>
                <View style={{flexDirection: 'row',alignItems:'center',}}>
                    <Image source={require('../../../img/hk_map_poi_icon.png')} style={styles.leftImage}/>
                    <View style={{marginLeft: 10,}}>
                        <Text style={{fontSize: 13, color: '#555555',}}>{rowData.rowID}{rowData.name.length>15?rowData.name.substring(0,15)+'...':rowData.name}</Text>
                        <Text style={{fontSize: 12, color: '#7B7B7B', marginTop: 3, }}>{rowData.address.length>20?rowData.address.substring(0,20)+'...':rowData.address}</Text>
                    </View>
                    {type!='search'?<View style={{marginRight:20, flex: 1,alignItems: 'flex-end'}}>
                        <Text style={{fontSize: 13, color: '#555555',}}>{rowData.distance>1000?(rowData.distance/1000).toFixed(2)+'km':rowData.distance.toFixed(2)+'m'}</Text>
                    </View>:null}
                </View>
            </TouchableOpacity>
        );
    }

    _renderNodata(){
        return (
            <View style={styles.noDataContent}>
                <Image source={require('../../../img/hk_no_data.png')} style={styles.leftImage}/>
                <Text style={{fontSize: 13, color: '#B5B5B5',marginTop:10}}>暂无搜索结果</Text>
            </View>
        );
    }

    _renderNoNearData(){
        return (
            <View style={styles.noDataContent} tabLabel="附近地址">
                <Image source={require('../../../img/hk_no_data.png')} style={styles.leftImage}/>
                <Text style={{fontSize: 13, color: '#B5B5B5',marginTop:10}}>暂无附近地址</Text>
            </View>
        );
    }

    _renderNoGPS(){
        return (
            <View style={styles.noDataContent}>
                <Text style={{fontSize: 13, color: '#B5B5B5',marginTop:10}}>您未开启定位功能</Text>
            </View>
        );
    }

    _searchNearBy(searchParams){
        this._amap.searchPoiByCenterCoordinate(searchParams);
    }

    _addressAction(){
        let {actions, dispatch, type, navigator, tab} = this.props;
        let {addressFirst, addressSecond, location} = this.state;

        let {address_store} = this.props;
        let address_left = address_store && address_store.split('\n')[0];
        let address_right = address_store && address_store.split('\n')[1];

        // addressFirst = addressFirst||address_left;
        // addressSecond = addressSecond||address_right;

        // location = location||location_store;
        let action;
        if(tab == 'send'){
            if(type == 'send'){
                action = actions.order.order_sendaddress(addressFirst+(addressSecond?'\n'+addressSecond:''), location);
            }else {
                action = actions.order.order_receiveaddress(addressFirst+(addressSecond?'\n'+addressSecond:''), location);
            }
        }else {
            if(type == 'send'){
                action = actions.order.order_buy_sendaddress(addressFirst+(addressSecond?'\n'+addressSecond:''), location);
            }else {
                action = actions.order.order_buy_receiveaddress(addressFirst+(addressSecond?'\n'+addressSecond:''), location);
            }
        }

        dispatch(action).then(() =>{
            InteractionManager.runAfterInteractions(() => {
                navigator.pop();
            });
        });
    }

    _setModalVisible(visible) {
        let {addressFirst, addressSecond} = this.state;
        this.setState({modalVisible: visible});
    }

    _editAddressInput(event) {
        // this.setState({editAddress: address});
        if(this.state.code){
            return;
        }

        this._searchIndicator && this._searchIndicator.setState({ visible: true,});
        // console.log("######", event.nativeEvent.text, "@@@@@", this.curCity);

        this._amap.searchPoiByKeywords({
            keywords: event.nativeEvent.text,
            requireSubPOIs: true,
            city: this.curCity
        });
    }

    _closeAction(){
        this.setState({
            openArrd: false
        });
    }

    render() {
        let {session} = this.props
        console.log('test--------d1',this.state.addrContent);
        console.log('test--------d',session.user.group);
        return (
            <View style={[styles.wrapper,{height: deviceHeight - 64}]}>
                    <View style={[styles.formContainer,{marginTop:0}]}>
                        <View style={styles.formItem}>
                            <TouchableOpacity style={styles.formSubItem} onPress={() =>{this._setModalVisible(true);}}>
                                <Image source={require('../../../img/hk_address1_icon.png')} style={styles.leftImage}/>
                                <TextInput
                                    style={styles.itemRight}
                                    editable={false}
                                    underlineColorAndroid={'#ffffff'}
                                    placeholder={'小区名字、大厦名、街道门牌号'}
                                    value={this.state.addressFirst}
                                    onChangeText={(addressFirst) => this.setState({addressFirst})}
                                    placeholderTextColor={'#B5B5B5'}
                                />
                            </TouchableOpacity>
                            {this.state.addrContent && session.user.productKey != "LiXiaoShuang"?
                            <TouchableOpacity onPress={this._addressYezhuAction.bind(this)}>
                                <Text style={styles.addressBtnText}>业主家</Text>
                            </TouchableOpacity>:null}
                        </View>

                        <View style={[styles.formItem,{borderBottomWidth:0}]}>
                            <Image source={require('../../../img/hk_address2_icon.png')} style={styles.leftImage}/>
                            <TextInput
                                value={this.state.addressSecond}
                                style={styles.itemRight}
                                editable = {true}
                                selectTextOnFocus={true}
                                onChangeText={(addressSecond) => {
                                    if(addressSecond.length > 20){
                                        addressSecond = addressSecond.substring(0,20);
                                        this.refs.toast.show('输入的最大字符不超过20');
                                    }
                                    this.setState({addressSecond});
                                }}
                                underlineColorAndroid={'#ffffff'}
                                placeholder={'楼层、门牌号'}
                                clearButtonMode={'while-editing'}
                                placeholderTextColor={'#B5B5B5'}
                            />
                            {this.state.addressFirst?
                            <TouchableOpacity onPress={this._addressAction.bind(this)}>
                                <Text style={styles.addressBtnText}>确定</Text>
                            </TouchableOpacity>:null}
                        </View>
                    </View>

                    <View style={styles.mapContainer}>
                        <View style={{position: 'relative', height: 175}}>
                            <AMap
                            ref={ component => this._amap = component }
                            style={{flex: 1, }}
                            options={{
                                frame: {
                                    width: deviceWidth,
                                    height: 175
                                },
                                showsUserLocation: true,
                                userTrackingMode: Platform.OS == 'ios' ? AMap.constants.userTrackingMode.none : null,
                                centerCoordinate: {
                                    latitude: this._coordinate.latitude,
                                    longitude: this._coordinate.longitude,
                                },
                                zoomLevel: 14.1,
                                centerMarker: Platform.OS == 'ios' ? 'icon_location' : 'marker_other_highlight',
                            }}
                            onDidMoveByUser={this._onDidMoveByUser.bind(this)}
                            />
                            <TouchableOpacity
                                style={{position: 'absolute', left: 15, bottom: 15, justifyContent: 'center', borderRadius: 3, justifyContent: 'center', }}
                                onPress={() => {
                                    // AMapLocation.init(null);
                                    AMapLocation.getLocation();
                                }}>
                                <Image source={require('../../../img/hk_map_location_icon.png')} />
                            </TouchableOpacity>
                       </View>
                        <View style={{flex: 1, position: 'relative',}}>
                            <ScrollableTabView
                                style={{marginTop:-7}}
                                onChangeTab={this._onChangeTab}
                                renderTabBar={() => (
                                    <DefaultTabBar
                                        activeTextColor={"#EA5404"}
                                        inactiveTextColor={"#555555"}
                                        textStyle={styles.textStyle}
                                        underlineStyle={styles.underlineStyle}
                                        style={styles.tabBar}
                                    />
                                )}>
                                {this.state.noneardata?this._renderNoNearData():<CustomListView
                                    tabLabel="附近地址"
                                    ref={ (component) => this._amapALoneNearByList = component }
                                    onRefresh={this._onRefresh.bind(this)}
                                    onLoadMore={this._onLoadMore.bind(this)}
                                    renderRow ={this._renderRow.bind(this)}
                                />}
                                <HistoryAddrList
                                    tabLabel="历史地址"
                                    parent={this}
                                    ref={(component) => this._historyListView = component }
                                    navigator={this.props.navigator}
                                />
                                <HistoryAddrList
                                    tabLabel="收藏地址"
                                    parent={this}
                                    status={1}
                                    ref={(component) => this._storeListView = component }
                                    navigator={this.props.navigator}
                                />
                            </ScrollableTabView>

                            <ListViewActivityIndicator
                                ref={ (component) => this._activityIndicator = component }
                                style={{marginRight: 10, position:'absolute', left: (deviceWidth - 20) / 2, top: (50 * 5 - 20) / 2, }}
                                color={'#a9a9a9'}/>
                        </View>
                    </View>
                    <Modal
                      transparent={true}
                      animationType="fade"
                      visible={this.state.modalVisible}
                      supportedOrientations={SUPPORTED_ORIENTATIONS}
                      onRequestClose={() => {this._setModalVisible(false);}}>
                        <View style={styles.modalContainer} onStartShouldSetResponderCapture={(e) => {
                            const focusField = TextInput.State.currentlyFocusedField();
                            if (focusField != null && e.nativeEvent.target != focusField){
                                dismissKeyboard();
                            }
                        }}>
                            <View style={[styles.formItem,{marginLeft:0,paddingLeft:15, backgroundColor: '#fff'}]}>
                                <Image source={require('../../../img/hk_search_icon.png')} style={styles.leftImage}/>
                                <TextInput
                                    style={styles.itemRight}
                                    value={this.state.editAddress}
                                    editable = {true}
                                    autoFocus={true}
                                    underlineColorAndroid={'#ffffff'}
                                    returnKeyType={'search'}
                                    placeholder={'小区名字、大厦名、街道门牌号'}
                                    clearButtonMode={'while-editing'}
                                    onChange={this._editAddressInput.bind(this)}
                                    onChangeText={(addr) =>{ this.setState({ editAddress: addr })}}
                                    placeholderTextColor={'#B5B5B5'}
                                />
                            <TouchableOpacity onPress={() =>{this._setModalVisible(false);this.setState({nodata:false});}}>
                                    <Text style={styles.searchCancelText}>取消</Text>
                                </TouchableOpacity>
                            </View>
                            {this.state.searchDataSource?<ListView
                				style={styles.searchListUser}
                				enableEmptySections
                				onEndReachedThreshold={1200}
                				dataSource={this.state.searchDataSource}
                				renderRow={(rowData, sectionID, rowID) =>{return this._renderRow(rowData, sectionID, rowID, 'search');}}
                			/>:(this.state.nodata?this._renderNodata():(this.state.code==13?this._renderNoGPS():null))}
                            <ListViewActivityIndicator
                                visible='hidden'
                                ref={ (component) => this._searchIndicator = component }
                                style={{marginRight: 10, position:'absolute', left: (deviceWidth - 20) / 2, top: 200, }}
                                color={'#a9a9a9'}/>
                        </View>
                    </Modal>
                    <SimpleDialog
                        offset={0}
                        open={this.state.openArrd}
                        closeOnTouchOutside={false}
                        containerStyle={{alignItems: 'center'}}
                        modalStyle={{padding:0,margin:15,width: 240,overflow:'hidden'}}
                        modalDidOpen={() => console.log('modal did open')}
                        style={{alignItems: 'center'}}>
                            <View style={styles.dialogContainer}>
                                <View style={{height:45, justifyContent: 'center', borderBottomWidth: 0.5, borderColor:'#ddd'}}><Text style={{color: '#565656', fontSize: 15, textAlign: 'center', fontWeight:'bold'}}>温馨提示</Text></View>
                                <TouchableOpacity onPress={this._closeAction.bind(this)} style={styles.closeIcon}>
                                    <Image source={require('../../../img/dialog_close.png')}/>
                                </TouchableOpacity>
                                <View style={{marginTop:25,justifyContent: 'center'}}>
                                    <Text style={{color: '#7B7B7B', fontSize: 14, textAlign: 'center',}}>无法获取到您的城市位置</Text>
                                    <Text style={{color: '#7B7B7B', fontSize: 14, textAlign: 'center',}}>请选择城市</Text>
                                </View>
                                <View style={{alignItems:'center',flex:1}}>
                                    <View style={styles.adrrsubmitBtnContainer}>
                                        <TouchableOpacity onPress={this._closeAction.bind(this)} style={[styles.adrrsubmitBtn,{marginRight:10,borderColor:'#DDD',borderWidth:0.5,borderRadius:2, backgroundColor:'#fff'}]}>
                                            <Text style={{color:"#565656",fontSize:15, }}>取消</Text>
                                        </TouchableOpacity>
                                        <TouchableOpacity onPress={this.openSelectCity.bind(this)} style={styles.adrrsubmitBtn}>
                                            <Text style={[styles.adrrsubmitBtnText,{}]}>确定</Text>
                                        </TouchableOpacity>
                                    </View>
                                </View>
                            </View>
                      </SimpleDialog>
                    <ToastTip ref="toast" offsetY={150}/>
            </View>
        );
    }
}

var connectHelper = require('../../services/connectHelper');
EditAddress = connectHelper(state => state)(EditAddress);

module.exports = EditAddress;
